package com.seecen.handler;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * @program: SharkBookkeeping-end
 * @description:
 * @author: XXW
 * @create: 2025-10-16 16:24
 * @version: 1.0
 **/
@Component
public class MyMetaObjectHandler implements MetaObjectHandler {
    @Override
    public void insertFill(MetaObject metaObject) {
        // 填充 createTime（插入时）
        this.strictInsertFill(metaObject, "createTime", Date.class, new Date());
        // 填充 lastUpdateTime（插入时）
        this.strictInsertFill(metaObject, "lastUpdateTime", Date.class, new Date());
    }

    @Override
    public void updateFill(MetaObject metaObject) {
        // 填充 lastUpdateTime（更新时）
        this.strictUpdateFill(metaObject, "lastUpdateTime", Date.class, new Date());
    }
}